package com.mcflies.ui.listView;

import java.io.IOException;
import java.util.List;

import android.app.ListActivity;
import android.os.Bundle;

import com.mcflies.ui.R;
import com.thoughtworks.xstream.XStream;

public class AsyncListViewActivity extends ListActivity {
	private AsyncListViewAdapter asyncListViewAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.async_listview_main);
		asyncListViewAdapter = new AsyncListViewAdapter(this, getList());
		this.setListAdapter(asyncListViewAdapter);
	}

	@SuppressWarnings("unchecked")
	private List<AsyncBean> getList() {
		try {
			XStream xStream = new XStream();
			xStream.alias("item", AsyncBean.class);
			return (List<AsyncBean>) xStream.fromXML(this.getAssets().open(
					"asyncListView/list.xml"));
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
}
